#ifndef GLWIDGET_H
#define GLWIDGET_H

#include <QGLWidget>
#include <QTimer>
#include <QTime>

enum GLColor
{
  GLCOLOR_RED,
  GLCOLOR_ORANGE,
  GLCOLOR_YELLOW,
  GLCOLOR_GREEN,
  GLCOLOR_BLUE,
  GLCOLOR_SIZE
};

const GLfloat GLColors[GLCOLOR_SIZE][3] =
{
  {1, 0, 0}, //red
  {1, 0.5, 0}, //orange
  {1, 1, 0}, //yellow
  {0, 1, 0}, //green
  {0, 0, 1} //blue
};

const GLfloat GLDarkColors[GLCOLOR_SIZE][3] =
{
  {0.5, 0, 0}, //red
  {0.5, 0.25, 0}, //orange
  {0.5, 0.5, 0}, //yellow
  {0, 0.5, 0}, //green
  {0, 0, 0.5} //blue
};

class GLWidget : public QGLWidget
{
  Q_OBJECT

public:
  GLWidget(QWidget* parent = 0, unsigned int fps = 30);
  virtual ~GLWidget();

protected:
  virtual void initializeGL();
  virtual void resizeGL(int w, int h);
  virtual void paintGL();
  virtual void keyPressEvent(QKeyEvent *e);

  void loadGLTexture(const QString& filename, GLuint textures[3]);
  void buildLists();

signals:
  void fps(unsigned int);

private:
  QTimer mTimer;
  QTime mTime;
  unsigned int mFramesPainted;

  GLuint mTextures[1];
  GLuint mBoxList;
  GLuint mTopList;
  double mXRot;
  double mYRot;
};

#endif
